// pages/myTreatorder/myTreatorder.js
const app = getApp();
Page({
  /**
   * 页面的初始数据
   */
  data: {
    statusBarHeight: app.globalData.statusBarHeight,
    fullHeight: app.globalData.fullcontain,
    navmess: {
      navtitle: "我的疗程订单",
      backhide: 0,
      topheight: 1,
    },
    currentTab: 0,
    height: 0,   //单个main高度
    widHeight: 0,  //swiper高度
    
    selectShow: false,
    selectData: ['全部','2','3'],//下拉列表的数据
    index: 0,//选择的下拉列表下标

    demolist:[
      {
        "startTime": "2020-06-06 （周四）15:00:30",
        "orderNo": "D2020060094",
        "treatname": "全身SPA激光美白疗程",
        "treatprice": "28888.00",
        "store": "深大店-深圳市",
        "place": "深圳市-宝安区-华丰国际机器人产业园B-404",
        "phone1": "0755-28018888",
        "phone2": "1212",
        "mrsname": "特朗普",
        "mrsphone": "2131232131",
        "surplus": "5",
        "stay": "38"
      }
    ],
    demolist2:[
      {
        "startTime": "2020-06-06 （周四）15:00:30",
        "orderNo": "D2020060094",
        "treatname": "全身SPA激光美白疗程",
        "treatprice": "28888.00",
        "store": "深大店-深圳市",
        "place": "深圳市-宝安区-华丰国际机器人产业园B-404",
        "phone1": "0755-28018888",
        "phone2": "1212",
        "mrsname": "特朗普",
        "mrsphone": "2131232131",
        "stay": "13"
      },
      {
        "startTime": "2020-06-06 （周四）15:00:30",
        "orderNo": "D2020060094",
        "treatname": "全身SPA激光美白疗程",
        "treatprice": "28888.00",
        "store": "深大店-深圳市",
        "place": "深圳市-宝安区-华丰国际机器人产业园B-404",
        "phone1": "0755-28018888",
        "phone2": "1212",
        "mrsname": "特朗普",
        "mrsphone": "2131232131",
        "stay": "8"
      }
    ],
    demolist3:[
      {
        "startTime": "2020-06-06 （周四）15:00:30",
        "orderNo": "D2020060094",
        "treatname": "全身SPA激光美白疗程",
        "treatprice": "28888.00",
        "store": "深大店-深圳市",
        "place": "深圳市-宝安区-华丰国际机器人产业园B-404",
        "phone1": "0755-28018888",
        "phone2": "1212",
        "mrsname": "特朗普",
        "mrsphone": "2131232131",
        "stay": "55"
      }
    ]
  },
  pageto: function(e){
    var url = e.currentTarget.dataset.url,
        data = e.currentTarget.dataset.datobj;
    app.goto(url,data);
  },
  // 动态获取赋值swiper-item高度
  savecurheight: function(count){
    var that = this,
        curmain =  '.main' + count,
        query = wx.createSelectorQuery().in(this);

    query.select(curmain).boundingClientRect(function (rect) { 
      console.log(rect)
      that.setData({
        height: rect.height
      })

      // 获取单个轮播循环的高度
      var heights=that.data.height;
      console.log(heights)
      // 获取一级成员的数组个数
      var item0 = that.data.demolist.length;
      // 获取二级成员的数组个数
      var item1 = that.data.demolist2.length;
      // 获取三级成员的数组个数
      var item2 = that.data.demolist3.length;
      
      if (that.data.currentTab==0){
        that.setData({
          widHeight: heights * item0+"px"
        });

      }else if(that.data.currentTab==1){
        that.setData({
          widHeight: heights * item1 + "px"
        });
        
      }else if(that.data.currentTab==2){
        that.setData({
          widHeight: heights * item2 + "px"
        });

      }
    }).exec();
     // 顶部开始显示
     this.setData({
      topNum: 0
    })
  },
  // 滑动切换tab
  bindChange: function (e) {
    var that = this;
    that.setData({
      currentTab: e.detail.current
    });
    this.savecurheight(e.detail.current);
  },
  // 点击tab切换
  swichNav: function (e) {
    var that = this;
    if (this.data.currentTab === e.target.dataset.current) {
      return false;
    } else {
      that.setData({
        currentTab: e.target.dataset.current
      })
    }
  },
  bindPickerChange: function(e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    this.setData({
      index: e.detail.value
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    this.savecurheight(0);  //默认取索引为0swiper高度
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})